<?php

namespace App\Http\Resources;

class AccountLogResource extends Resource
{
    /**
     * Transform the resource collection into an array.
     *
     * @param \Illuminate\Http\Request $request
     *
     * @return array
     */
    public function toArray($request)
    {

        return [
            'type' => $this->getType(),
            'number' => bcadd($this->number, 0, 4),
            'time' => $this->time,
        ];
    }

    private function getType()
    {
        switch ($this->type) {
            case '兑换':
                return '兑换得到';
                break;
            default:
                return $this->type;
                break;
        }
    }
}
